//
//  RandomUtils.m
//  ConfuseTooles
//
//  Created by vincent on 2018/5/7.
//  Copyright © 2018年 vincent. All rights reserved.
//

#import "RandomUtils.h"

@implementation RandomUtils


+(NSString *) getRandomStr:(int)max with:(NSArray *)list {
  NSArray *tList = list;
  if (!list || list.count == 0) {
    tList = @[@"0123456789"
                            ,@"abcdefghijklmnopqrstuvwxyq"
                            ,@"ABCDEFGHIJKLMNOPQRSTUVWXYQ"];
  }
  
  int strLen = 1 + arc4random() % (max -1);
  
  NSString *str = @"";
  for (int i = 0;i<strLen;i++) {
    int x = arc4random()%tList.count;
    NSString *source = [tList objectAtIndex:x];
    int y = arc4random()%source.length;
    NSRange range = NSMakeRange(y, 1);
    str = [str stringByAppendingString:[source substringWithRange:range]];
  }
  return str;
}

+(NSString *) getRandomFilePath:(NSString *)path maxLevel:(int)maxLevel {
  int dLevel = arc4random()%maxLevel;
  NSString *tPath = [NSString stringWithFormat:@"%@",path];
  for (int i=0;i<dLevel;i++) {
    tPath = [tPath stringByAppendingPathComponent:[self getRandomStr:30 with:nil]];
  }
  return tPath;
}

     
     
    

@end
